package com.rui.strategy.obj.pay;

/**
 * @Description: 支付方式抽象类
 * @Author: ZhangRui
 * @Date: 2023/3/3 13:42
 * @Version: 1.0
 */
public abstract class Payment {

    public String pay(String uid, double money) {
        double balance = queryBalance(uid);
        if (balance < money) {
            return "支付失败!余额不足!欠" + (money - balance) + "元!";
        }
        return "支付成功!支付金额:" + money + "余额剩余:" + (balance - money);
    }

    /**
     * 支付类型
     *
     * @param null
     * @return
     * @author ZhangRui
     * @date 2023/3/3 13:54
     */
    public abstract String getPaymentName();

    /**
     * 账户余额
     *
     * @param uid
     * @return double
     */
    protected abstract double queryBalance(String uid);
}
